package com.paomi.client.activity.detail.model;

import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Region;

import com.paomi.client.bean.BaseJSON;
import com.paomi.client.view.svg.PathParser;

import java.io.Serializable;
import java.util.List;

/**
 * Created by pc on 2018/11/22
 * Describe:在线选座的接口
 * "returnData": {
 * "info": {
 * "high": "1000",//高
 * "wide": "1000",//宽
 * "background": "http://image.mydeershow.com/upload/image/20181102/2b3a523f-01a0-47f4-bec7-029f8dae3958.png",//背景图
 * "shrinkage_bureau_figure": "http://image.mydeershow.com/upload/image/20181119/897d0b98-0e62-47ad-a319-472f889f96ff.png",//缩局图
 * },
 * "sections": [//n个区域
 * {
 * "id": 1035,
 * "sectionName": "A_left",//区域名称
 * "fillcolor": "white",
 * "sectionPath": "M 223 280 H 323 V 422 H 192 V 320 h 31 V 280 Z",
 * }
 * ],
 * "colors": [//n个色块
 * {
 * "id": 6,
 * "sectionId": 1035,
 * "name": "aaa",//色块名称
 * "svgCode": "M225,282h96V420H195l-1-98h31V282Z",
 * "colorCode": "#58c3bd",
 * }
 * ],
 * "tickets": [//n个座位
 * {
 * "id": 9,
 * "sectionId": 36,
 * "colorId": 6,
 * "price": "100.00",//价格
 * "state": 0,//0 可售 1 不可售
 * "num": "1",//数量
 * "row": 5,//第几排
 * "columns": 12,//几号座位
 * "x": "355.33274",
 * "y": "370.73136"
 * }
 * ]
 * }
 * com.paomi.client.activity.detail.model
 */
public class OnlineSiteBean extends BaseJSON {
    private OnlineBean returnData;

    public OnlineBean getReturnData() {
        return returnData;
    }

    public void setReturnData(OnlineBean returnData) {
        this.returnData = returnData;
    }

    public class OnlineBean implements Serializable {
        private InfoBean info;
        private List<SectionBean> sections;
        private List<ColoesBean> colors;
        private List<TicketsBean> tickets;

        public InfoBean getInfo() {
            return info;
        }

        public void setInfo(InfoBean info) {
            this.info = info;
        }

        public List<SectionBean> getSections() {
            return sections;
        }

        public void setSections(List<SectionBean> sections) {
            this.sections = sections;
        }

        public List<ColoesBean> getColors() {
            return colors;
        }

        public void setColors(List<ColoesBean> colors) {
            this.colors = colors;
        }

        public List<TicketsBean> getTickets() {
            return tickets;
        }

        public void setTickets(List<TicketsBean> tickets) {
            this.tickets = tickets;
        }
    }

    /**
     * "info": {
     * "high": "1000",//高
     * "wide": "1000",//宽
     * "background": "http://image.mydeershow.com/upload/image/20181102/2b3a523f-01a0-47f4-bec7-029f8dae3958.png",//背景图
     * "shrinkage_bureau_figure": "http://image.mydeershow.com/upload/image/20181119/897d0b98-0e62-47ad-a319-472f889f96ff.png",//缩局图
     * }
     */
    public class InfoBean implements Serializable {
        private String high;
        private String wide;
        private String background;
        private String shrinkage_bureau_figure;

        public String getHigh() {
            return high;
        }

        public void setHigh(String high) {
            this.high = high;
        }

        public String getWide() {
            return wide;
        }

        public void setWide(String wide) {
            this.wide = wide;
        }

        public String getBackground() {
            return background;
        }

        public void setBackground(String background) {
            this.background = background;
        }

        public String getShrinkage_bureau_figure() {
            return shrinkage_bureau_figure;
        }

        public void setShrinkage_bureau_figure(String shrinkage_bureau_figure) {
            this.shrinkage_bureau_figure = shrinkage_bureau_figure;
        }
    }

    /**
     * {
     * "id": 1035,
     * "sectionName": "A_left",//区域名称
     * "fillcolor": "white",
     * "sectionPath": "M 223 280 H 323 V 422 H 192 V 320 h 31 V 280 Z",
     * }
     */
    public static class SectionBean implements Serializable {
        private int id;
        private String sectionName;
        private String fillcolor;
        private String sectionPath;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getSectionName() {
            return sectionName;
        }

        public void setSectionName(String sectionName) {
            this.sectionName = sectionName;
        }

        public String getFillcolor() {
            return fillcolor;
        }

        public void setFillcolor(String fillcolor) {
            this.fillcolor = fillcolor;
        }

        public String getSectionPath() {
            return sectionPath;
        }

        public void setSectionPath(String sectionPath) {
            this.sectionPath = sectionPath;
        }


        //以下是针对svg图来加载
        //添加初始化的坐标点
        private Path mPath;
        private Region re=new Region();
        public Path getmPath() {
            return mPath;
        }

        /**
         * 初始化path值
         */
        public void initPath(){
            mPath = PathParser.createPathFromPathData(sectionPath);
        }
        public boolean isArea(float x,float y){
            RectF r=new RectF();
            //计算控制点的边界
            mPath.computeBounds(r, true);
            //设置区域路径和剪辑描述的区域
            re.setPath(mPath, new Region((int)r.left,(int)r.top,(int)r.right,(int)r.bottom));
            return  re.contains((int)x, (int)y);
        }
    }

    /**
     * {
     * "id": 6,
     * "sectionId": 1035,
     * "name": "aaa",//色块名称
     * "svgCode": "M225,282h96V420H195l-1-98h31V282Z",
     * "colorCode": "#58c3bd",
     * }
     */
    public class ColoesBean implements Serializable {
        private int id;
        private int sectionId;
        private String name;
        private String svgCode;
        private String colorCode;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public int getSectionId() {
            return sectionId;
        }

        public void setSectionId(int sectionId) {
            this.sectionId = sectionId;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getSvgCode() {
            return svgCode;
        }

        public void setSvgCode(String svgCode) {
            this.svgCode = svgCode;
        }

        public String getColorCode() {
            return colorCode;
        }

        public void setColorCode(String colorCode) {
            this.colorCode = colorCode;
        }
    }

    /**
     * {
     * "id": 9,
     * "sectionId": 36,
     * "colorId": 6,
     * "price": "100.00",//价格
     * "state": 0,//0 可售 1 不可售
     * "num": "1",//数量
     * "row": 5,//第几排
     * "columns": 12,//几号座位
     * "x": "355.33274",
     * "y": "370.73136"
     * }
     */
    public class TicketsBean implements Serializable {
        private int id;
        private int sectionId;
        private int colorId;
        private String price;
        private int state;
        private String num;
        private int row;
        private int columns;
        private String x;
        private String y;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public int getSectionId() {
            return sectionId;
        }

        public void setSectionId(int sectionId) {
            this.sectionId = sectionId;
        }

        public int getColorId() {
            return colorId;
        }

        public void setColorId(int colorId) {
            this.colorId = colorId;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public int getState() {
            return state;
        }

        public void setState(int state) {
            this.state = state;
        }

        public String getNum() {
            return num;
        }

        public void setNum(String num) {
            this.num = num;
        }

        public int getRow() {
            return row;
        }

        public void setRow(int row) {
            this.row = row;
        }

        public int getColumns() {
            return columns;
        }

        public void setColumns(int columns) {
            this.columns = columns;
        }

        public String getX() {
            return x;
        }

        public void setX(String x) {
            this.x = x;
        }

        public String getY() {
            return y;
        }

        public void setY(String y) {
            this.y = y;
        }
    }
}
